class Account {

    constructor() {
        this.acc = { "rank": 1234 };
        this.idCardName = "manage-system-backed-idCard";
        this.idCard = localStorage.getItem(this.idCardName) || "";
    }

    loadAccount() {
        this.getAccount();
    }

    //获取身份权限匹配的用户信息
    getAccount() {

        var load = this;

        $.ajax({
            url: "/Lock/GetAcc",
            type: 'get',
            data: {
                // "idCard": this.idCard
            },
            success: function (req) {


                if (req.statue != 0) {
                    layui.layer.msg("获取账号信息失败!");
                    // load.acc = {};//空对象
                    return;
                }
                // load.acc = req;
                console.log(req);

                load.renderAccount(req.acc);

                $("#main-layui-body").children().hide();

            },

        });

        // $.get("/Lock/GetAcc",{abc: 123,
        // idCard: localStorage.getItem("manage-system-backed-idCard")},function(req){
        //     console.log(req);
        // });

        // $.post("/Lock/GetAcc",{idCard: localStorage.getItem("manage-system-backed-idCard")},function(req){
        //     console.log(req);
        // })

    };

    renderAccount(acc) {

        acc.avater = undefined;

        if (acc.avater) {
            $(".layui-nav-img").show().attr("src", acc.avater);
            $(".layui-n av-tree .avater-box .text-avater").hide();
            $(".layui-layout-right .layui-hide .text-avater").hide();
        } else {
            $(".layui-nav-img").hide();
            $(".layui-nav-tree .avater-box .text-avater").show().text((acc.tname || acc.sname || acc.aid)[0].toUpperCase());
            $(".layui-layout-right .layui-hide .text-avater").text((acc.tname || acc.sname || acc.aid)[0].toUpperCase());
        }

        $("span.acc-aid").text((acc.aid || "***"));

    };
}